#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 1e6 + 5;
int T,n,m,L,V,d[N],v[N],a[N],p[N],ans1,ans2,lft[N],rgt[N],cnt[N];
bool camera[N],used[N];

bool check() {
    for(int i = 1; i <= n; i++) {
        if(a[i]) return false;
    }
    return true;
}
bool judge(int x) {

}
signed main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> T;
    while(T--) {
        cin >> n >> m >> L >> V;
        ans1 = 0;
        ans2 = 0;
        memset(d,0,sizeof(d));
        memset(v,0,sizeof(v));
        memset(a,0,sizeof(a));
        memset(p,0,sizeof(p));
        memset(camera,false,sizeof(camera));
        memset(lft,0,sizeof(lft));
        memset(rgt,0,sizeof(rgt));
        for(int i = 1; i <= n; i++) {
            cin >> d[i] >> v[i] >> a[i];
        }
        for(int i = 1; i <= m; i++) {
            cin >> p[i];
            camera[p[i]] = true;
        }
        if(check()) {
            for(int i = 1; i <= n; i++) {
                if(v[i] > V && d[i] <= p[m]) {
                    ans1++;
                }
            }
            cout << ans1 << " ";
            if(ans1) {
                cout << m - 1 << "\n";
            }
            else {
                cout << m << "\n";
            }
            continue;
        }
        for(int i = 1; i <= n; i++) {
            if(a[i] == 0) {
                if(v[i] > V && d[i] <= p[m]) {
                    ans1++;
                    lft[i] = d[i];
                    rgt[i] = L;
                }
            }
            else if(a[i] < 0){
                if(v[i] > V) {
                    int s = floor((V * V - v[i] * v[i]) / 2 / a[i]);
                    for(int j = d[i]; j <= min(L,d[i] + s); j++) {
                        if(camera[j]) {
                            ans1++;
                            lft[i] = d[i];
                            rgt[i] = d[i] + s;
                            break;
                        }
                    }
                }
            }
            else if(a[i] > 0) {
                if(v[i] > V && d[i] <= p[m]) {
                    ans1++;
                    lft[i] = d[i];
                    rgt[i] = L;
                }
                else if(v[i] <= V){
                    int s = floor((V * V - v[i] * v[i]) / 2 / a[i]);
                    for(int j = d[i] + s + 1; j <= L; j++) {
                        if(camera[j]) {
                            ans1++;
                            lft[i] = d[i] + s + 1;
                            rgt[i] = L;
                            break;
                        }
                    }
                }
            }
        }
        cout << ans1 << " " ;
        memset(cnt,0,sizeof(cnt));
        for(int i = 1; i <= n; i++) {
            if(lft[i] && rgt[i])
                for(int j = lft[i]; j <= rgt[i]; j++) {
                    if(camera[j])
                        cnt[j]++;
                }
        }
        memset(used,false,sizeof(used));
        for(int i = 1; i <= n; i++) {
            if(!used[i] && lft[i] && rgt[i]) {
                ans2++;
                int maxn = 0,maxs = 0;
                for(int j = lft[i]; j <= rgt[i]; j++) {
                    if(camera[j] && cnt[j] > maxs) {
                        maxs = cnt[j];
                        maxn = j;
                    }
                }
                for(int j = 1; j <= n; j++) {
                    if(!used[j] && lft[j] <= maxn && rgt[j] >= maxn) {
                        used[j] = true;
                    }
                }
            }
        }
        cout << m - ans2 << "\n";
    }
    return 0;
}
